package com.gyl.service.Impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.gyl.domain.Employee;
import com.gyl.domain.PageListRes;
import com.gyl.domain.QueryVo;
import com.gyl.mapper.EmployeeMapper;
import com.gyl.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmployeeServiceImpl implements EmployeeService {
    @Autowired
    private EmployeeMapper employeeMapper;
    @Override
    public PageListRes getAllEmployee(QueryVo vo) {
        /*调用mapper 查询员工 */
        Page<Object> page = PageHelper.startPage(vo.getPage(), vo.getRows());
        System.out.println("employeeList==================服务层");
        List<Employee> employees = employeeMapper.selectAll(vo);
        System.out.println("employee列表已查出----------------------");
        /*封装成pageList*/
        PageListRes pageListRes = new PageListRes();
        pageListRes.setTotal(page.getTotal());
        pageListRes.setRows(employees);
        return pageListRes;
    }
}
